package com.dongbo.recorder.screenrecord.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.dongbo.recorder.screenrecord.AppLpds;
import com.dongbo.recorder.screenrecord.Constants;
import com.dongbo.recorder.screenrecord.R;
import com.dongbo.recorder.screenrecord.base.BaseActivity;
import com.dongbo.recorder.screenrecord.cache.MySp;
import com.gyf.immersionbar.ImmersionBar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author GuoZi
 * @date :2020/5/5 12:42
 * @description: 首次启动页
 */
public class FirstActivity extends BaseActivity {
    @BindView(R.id.first_btn)
    Button firstBtn;
    @BindView(R.id.first_agree)
    ImageView firstAgree;

    private boolean isAgree = true;

    @Override
    protected int getLayout() {
        return R.layout.activity_first;
    }

    @Override
    protected void initView() {
        checkAgree();
    }

    @Override
    protected void initData() {
        ImmersionBar.with(this).transparentStatusBar().init();
    }

    @Override
    protected void initListener() {

    }

    @OnClick({R.id.first_btn,
            R.id.tv_user_agreement,
            R.id.tv_privacy_policy,
            R.id.first_agree})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.first_btn:
                if (!isAgree) {
                    showToast(getResources().getString(R.string.tips_agreement));
                    return;
                }
                AppLpds.getMySp().putBoolean(MySp.ISFIRST, false);
                startActivity(new Intent(FirstActivity.this, MainActivity.class));
                FirstActivity.this.finish();
                break;
            case R.id.tv_user_agreement://用户协议
                WebActivity.start(FirstActivity.this,
                        "用户协议",
                        Constants.BASE_URL + "app/article/u/protocolInfo?protocolId=f9da6036f2294ea9824830d0601b4eda");
                break;
            case R.id.tv_privacy_policy://隐私政策

                WebActivity.start(FirstActivity.this,
                        "隐私政策",
                        Constants.BASE_URL + "app/article/u/protocolInfo?protocolId=c099b1915f2d4a0daaf7781578da0e17");

                break;
            case R.id.first_agree:
                isAgree = !isAgree;
                checkAgree();
                break;
        }
    }

    private void checkAgree() {
        if (isAgree) {
            firstAgree.setImageResource(R.mipmap.check_select_icon);
        } else {
            firstAgree.setImageResource(R.mipmap.check_icon);
        }
    }
}
